// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

using System.Collections.Generic;

namespace SnapObjects.Data
{
    /// <summary>
    ///     Represents the save context when saving the data changes to the database. It provides a series
    ///     of methods for reading or manipulating the save context.
    /// </summary>
    public interface ISaveContext
    {
        /// <summary>
        ///     Gets the result of the most recent operation that uses the model to save data to the database.
        /// </summary>
        IDbResult LastDbResult { get; }

        /// <summary>
        ///     Cancels the operation that is currently being executed to save the data to the database.
        /// </summary>
        void CancelSave();

        /// <summary>
        ///     Gets the number of the added values in the ISaveContext object..
        /// </summary>
        int Count { get; }

        /// <summary>
        ///     Gets the names of all of the added values.
        /// </summary>
        IReadOnlyList<string> Names { get; }

        /// <summary>
        ///     Returns whether the ISaveContext object contains the specified value.
        /// </summary>
        /// <param name="name">Name of the specified value.</param>
        /// <returns>
        ///     Whether the save context contains the specified value.
        ///     True: the ISaveContext object contains the specified value.
        ///     False: the ISaveContext object does not contain the specified value.
        /// </returns>
        bool Contains(string name);

        /// <summary>
        ///     Gets the specified value from the ISaveContext object..
        /// </summary>
        /// <param name="name">Name of the specified value.</param>
        /// <returns>The specified value.</returns>
        object Get(string name);

        /// <summary>
        ///     Adds a value of any data type and its name to the ISaveContext object.
        /// </summary>
        /// <param name="name">The name of the value to be added.</param>
        /// <param name="value">The value of any data type to be added.</param>
        void Add(string name, object value);

        /// <summary>
        ///     Removes the specified value from the ISaveContext object.
        /// </summary>
        /// <param name="name">Name of the specified value.</param>
        void Remove(string name);

        /// <summary>
        ///     Removes all of the added values from the ISaveContext object.
        /// </summary>
        void RemoveAll();
    }
}
